package com.example.tool.bean.ddaiexcel;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 钉钉AI表格支持的字段类型枚举
 */
@Getter
@AllArgsConstructor
public enum DDFieldType {
    TEXT("text", "文本类型"),
    NUMBER("number", "数字类型"),
    DATE("date", "日期类型"),
    DATETIME("datetime", "日期时间类型"),
    CHECKBOX("checkbox", "复选框类型"),
    SELECT("select", "下拉选择类型"),
    USER("user", "用户类型"),
    ATTACHMENT("attachment", "附件类型"),
    LINK("link", "链接类型"),
    FORMULA("formula", "公式类型"),
    AUTO_NUMBER("autoNumber", "自动编号类型");

    private final String code;

    private final String description;

    /**
     * 根据code获取枚举实例
     */
    public static DDFieldType fromCode(String code) {
        for (DDFieldType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的字段类型: " + code);
    }


    @Override
    public String toString() {
        return code;
    }
}